<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>食堂配送系统</title>
    <meta name=viewport content="width=device-width,minimum-scale=1,maximum-scale=1,initial-scale=1,user-scalable=no">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.10/vue.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <link rel="stylesheet" href="/common/index.css">
    <script src="/common/index.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/layer/2.3/layer.js"></script>
</head>
<body>
<div id="id-app" v-cloak>
    <div class="login-container shadow">
        <div class="login-header fwBlod fs24">
            <font>登陆</font>
        </div>
        <div class="login-item mt20 fs20">
            用户名:
        </div>
        <div class="login-item mt10">
            <el-input v-model="username" placeholder="用户名"></el-input>
        </div>
        <div class="login-item mt20 fs20">
            密码:
        </div>
        <div class="login-item mt10">
            <el-input v-model="password" type="password" placeholder="密码"></el-input>
        </div>
        <div class="login-item mt10">
            <el-checkbox size="medium" v-model="rememberMe">保持30天登陆</el-checkbox>
        </div>
        
        <div class="login-item tac mt30">
            <div @click="memberLogin()" class="commBtn mAuto borderRadius">登陆</div>
        </div>
        <div class="login-item mt10">
            <div class="login-hint fs14 tac"></div>
        </div>
    </div>

</div>
<script>
    var index = new Vue({
        el: '#id-app',
        data: {
            username: null,
            password: null,
            isLogin: checkLogin(),
            rememberMe: false,
        },
        methods: {
            memberLogin() {
                var _this = this
                AjaxPostAsync('Home/Index/login', {
                    username: _this.username,
                    password: _this.password,
                    rememberMe: _this.rememberMe
                }, function (data) {
                    if (data.status == true) {
                        layer.msg(data.message)
                        saveLogin(data.data.username, data.data.memberID,_this.rememberMe)
                        window.location.href = '{:U("/Home/Index/member")}'
                    } else {
                        layer.msg(data.message)
                    }
                })
            },

        },
        watch: {},
        mounted() {
            if (checkLogin() == true) {
                window.location.href = '{:U("/Home/Index/member")}'
                if(getUrlParamValue('h')==1){
                    window.location.href = '{:U("/Home/Index/member/")}'+"?h=1"
                }
            }
            var _this = this
            window.addEventListener('keyup',function (key) {
                if(key.key=="Enter"){
                    _this.memberLogin()
                }
            
            })
        }
    })
</script>
</body>
</html>